//********************************************/
// Creation History
// Company : HTHK
// Name    : DivisionSearch.java
// Function : Division Master
// By       : Miranda Lin
// Date     : 11-Aug-2004 CRLOG 1347
/*********************************************/

package admin.system.division;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.servlet.*;
import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

/**
 * A Class class.
 * <P>
 * @author HTHK
 */
public class DivisionSearch
  extends DBServlet {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      DivisionBean division = DivisionProcess.createBean();
      division.setDivision_id(request.getParameter("division_id"));
      division.setDivision_name(request.getParameter("division_name"));
      DivisionBean[] div = DivisionProcess.find(this.getConnection(),division);
      if (div==null || div.length==0)
      {
          message.setMessage("No record, please input another criteria.");
          return "system/DivisionSearch.jsp";
      }
      else if (div.length==1)
      {
          request.setAttribute("division",div[0]);
          return "system/Division.jsp?formAction=Update";
      }
      else
      {
          request.setAttribute("division",div);
          return "system/DivisionList.jsp";
      }
  }
}


